package com.huawei.appmarket.service.infoflow.view.widget;

import android.content.Context;
import android.text.TextUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.ViewTreeObserver;
import android.view.ViewTreeObserver.OnGlobalLayoutListener;
import android.widget.LinearLayout;
import huawei.widget.HwTextView;
import o.azb;
import o.dky.h;
import o.dky.i;
import o.Logger;

public class HeaderView extends LinearLayout {
    private LinearLayout ˋ;
    private HwTextView ˎ;
    private LinearLayout ˏ;
    private d ॱ;

    public interface d {
        void ˎ();
    }

    public HeaderView(Context context) {
        super(context);
        ˊ(context);
    }

    public HeaderView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ˊ(context);
    }

    private void ˊ(Context context) {
        LayoutParams layoutParams = new LinearLayout.LayoutParams(-1, -2);
        this.ˏ = (LinearLayout) LayoutInflater.from(context).inflate(i.ˌ, null);
        this.ˋ = (LinearLayout) this.ˏ.findViewById(h.ˊᐝ);
        this.ˎ = (HwTextView) this.ˏ.findViewById(h.ˊˋ);
        azb.ˋ(this.ˎ);
        addView(this.ˏ, layoutParams);
        ViewTreeObserver viewTreeObserver = getViewTreeObserver();
        if (viewTreeObserver != null) {
            viewTreeObserver.addOnGlobalLayoutListener(new OnGlobalLayoutListener(this) {
                final /* synthetic */ HeaderView ˎ;

                {
                    this.ˎ = r1;
                }

                public void onGlobalLayout() {
                    ViewTreeObserver viewTreeObserver = this.ˎ.getViewTreeObserver();
                    if (viewTreeObserver != null) {
                        viewTreeObserver.removeOnGlobalLayoutListener(this);
                    }
                    if (this.ˎ.ॱ != null) {
                        this.ˎ.ॱ.ˎ();
                    }
                }
            });
        }
    }

    public void setILayoutEndListener(d dVar) {
        this.ॱ = dVar;
    }

    public void setLoadingTips(String str) {
        if (!TextUtils.isEmpty(str) && this.ˎ != null) {
            this.ˎ.setText(str);
        }
    }

    public int ॱ() {
        return this.ˏ.getLayoutParams().height;
    }

    public void setVisibleHeight(int i) {
        if (i < 0) {
            Logger.ˋ("HeaderView", "setVisibleHeight, height = " + i);
            i = 0;
        }
        LinearLayout.LayoutParams layoutParams = (LinearLayout.LayoutParams) this.ˏ.getLayoutParams();
        layoutParams.height = i;
        this.ˏ.setLayoutParams(layoutParams);
    }

    public void setVisibility(int i) {
        this.ˋ.setVisibility(i);
        super.setVisibility(i);
    }
}
